package cn.ycq.im.chat;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.List;

/**
 * @author yuchaoqun
 * @email chaoqunyu9311@163.com
 * @date 2021.03.07 13:49
 */
public class MessageBuildUtils {

    public static CmdTransport getSystemMessage(String message){
        CmdTransport transport = new CmdTransport();
        transport.setCmd(CmdType.SYSTEM.getValue());
        transport.put("msg",message);
        transport.put("type",1);
        transport.put("showType",1);
        transport.put("sendTime", LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
        return transport;
    }

    public static CmdTransport getChatMessage(int cmd, String name, String msg) {
        CmdTransport transport = new CmdTransport();
        transport.setCmd(cmd);
        transport.put("showType",1);
        transport.put("msg",msg);
        transport.put("type",1);
        transport.put("sender",name);
        transport.put("sendTime", LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
        return transport;
    }

    public static CmdTransport getPushOnlineMessage(Long online) {
        CmdTransport transport = new CmdTransport();
        transport.setCmd(CmdType.SYSTEM.getValue());
        transport.put("online",online);
        transport.put("type",2);
        transport.put("sendTime", LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
        return transport;
    }

    public static CmdTransport getPushOnlineUserListMessage(List<String> onlineList) {
        CmdTransport transport = new CmdTransport();
        transport.setCmd(CmdType.SYSTEM.getValue());
        transport.put("onlineList",onlineList);
        transport.put("type",3);
        transport.put("sendTime", LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
        return transport;
    }
}
